﻿
# Artifact Script Triggers
artifact_value_trigger = {
	trigger_if = {
		limit = {
			exists = $VALUE$
		}
		$VALUE$ >= $MIN$
		$VALUE$ < $MAX$
	}
	trigger_else_if = {
		limit = {
			$MIN$ < 50
		}
		artifact_low_rarity_trigger = yes
	}
	trigger_else_if = {
		limit = {
			$MIN$ > 50
			$MAX$ < 70
		}
		artifact_medium_rarity_trigger = yes
	}
	trigger_else = {
		artifact_high_rarity_trigger = yes
	}
}

artifact_region_trigger = {
	trigger_if = {
		limit = {
			any_in_list = {
				list = artifact_material_sources
				exists = this
			}
		}
		any_in_list = {
			list = artifact_material_sources
			geographical_region = $REGION$
		}
	}
	trigger_else_if = {
		limit = {
			exists = $CHARACTER$
		}
		$CHARACTER$ = {
			trigger_if = {
				limit = {
					exists = capital_province
				}
				capital_province = { geographical_region = $REGION$ }
			}
			trigger_else_if = {
				limit = { exists = location }
				location = { geographical_region = $REGION$ }
			}
			trigger_else = {
				#no location
			}
		}
	}
	trigger_else_if = {
		limit = { exists = scope:artifact.artifact_owner }
		scope:artifact.artifact_owner = {
			trigger_if = {
				limit = {
					exists = capital_province
				}
				capital_province = { geographical_region = $REGION$ }
			}
			trigger_else_if = {
				limit = { exists = location }
				location = { geographical_region = $REGION$ }
			}
			trigger_else = {
				#no location
			}
		}
	}
	trigger_else = {
		trigger_if = {
			limit = {
				exists = capital_province
			}
			capital_province = { geographical_region = $REGION$ }
		}
		trigger_else_if = {
			limit = { exists = location }
			location = { geographical_region = $REGION$ }
		}
		trigger_else = {
			#no location
		}
	}
}

artifact_has_religious_decorations_trigger = {
	OR = {
		has_artifact_feature = decoration_pattern_war_god
		has_artifact_feature = decoration_pattern_religion
		has_artifact_feature = decoration_pattern_religious_symbol
		has_artifact_feature = decoration_pattern_eschatology
		has_artifact_feature = icon_decoration_pattern_saint
	}
}

artifact_has_pattern_trigger = {
	artifact_needs_pattern_trigger = yes
}

artifact_needs_pattern_trigger = {
	# Check if one of our artifact features needs a pattern reference
	OR = {
		# Weapons
		has_artifact_feature = blade_decoration_etched_pattern
		has_artifact_feature = hilt_decoration_carved_pattern
		has_artifact_feature = hilt_decoration_inlay_pattern
		has_artifact_feature = head_decoration_etched_pattern
		has_artifact_feature = shaft_decoration_painted_pattern
		has_artifact_feature = metal_handle_decoration_etched_pattern

		# Armor
		has_artifact_feature = armor_decoration_etched_pattern
		has_artifact_feature = armor_decoration_inlay_pattern
		has_artifact_feature = armor_decoration_painted_pattern

		# Furniture
		has_artifact_feature = wood_decoration_painted_pattern

		# Box
		has_artifact_feature = box_decoration_painted
		has_artifact_feature = box_decoration_carved

		# Bowl
		artifact_type = bowl

		# Plate
		artifact_type = plate
	}
}

artifact_needs_material_inlay_trigger = {
	# Check if one of our artifact features needs a material reference for inlay
	OR = {
		# Weapons
		has_artifact_feature = hilt_decoration_inlay_pattern
		has_artifact_feature = hilt_decoration_rounded_pommels
		has_artifact_feature = hilt_decoration_twisting
		has_artifact_feature = metal_handle_decoration_inlay

		# Armor
		has_artifact_feature = armor_decoration_inlay_pattern

		# Box
		has_artifact_feature = box_decoration_inlay

		# Alchemy - Elixir
		has_artifact_feature = glass_decoration_inlay_pattern
	}
}

artifact_needs_material_wire_trigger = {
	# Check if one of our artifact features needs a material reference for precious metal wire or other jewelery-like fastenings
	OR = {
		# Weapons
		has_artifact_feature = hilt_decoration_wires
		has_artifact_feature = hilt_decoration_filigree
		has_artifact_feature = hilt_decoration_circles

		# Armor
		has_artifact_feature = armor_decoration_lining
		has_artifact_feature = armor_decoration_embossed
		has_artifact_feature = armor_decoration_grouped_rivets

		# Ring
		has_artifact_feature = ring_centerpiece_signet
		has_artifact_feature = ring_centerpiece_religious
		has_artifact_feature = ring_adornment_runes

		# Necklace
		artifact_type = necklace
		artifact_type = necklace_pedestal
	}
}

artifact_needs_material_cloth_trigger = {
	# Check if one of our artifact features needs a material reference for cloth lining
	OR = {
		# Armor
		has_artifact_feature = armor_helmet_nasal
		has_artifact_feature = armor_helmet_enclosed
		has_artifact_feature = armor_helmet_great_helmet
		has_artifact_feature = armor_helmet_cervelliere
	}	
}

artifact_needs_material_gem_trigger = {
	OR = {
		has_artifact_feature = crown_decoration_gems
		has_artifact_feature = crown_decoration_filigree_and_gem
		has_artifact_feature = brooch_centerpiece_cabochon
		has_artifact_feature = brooch_adornment_gems
		has_artifact_feature = ring_centerpiece_cabochon
		has_artifact_feature = ring_adornment_gems
		has_artifact_feature = book_decoration_gems
		has_artifact_feature = book_decoration_gems_and_clasp

		artifact_type = necklace
		artifact_type = necklace_pedestal
	}
}

artifact_needs_material_hsb_trigger = {
	OR = {
		has_artifact_feature = wood_decoration_hsb_inlay
		has_artifact_feature = shaft_decoration_inlay
	}	
}

artifact_needs_material_wood_trigger = {
	has_artifact_feature = book_cover_material_wood
}


############################
# Artifact Visual Triggers #
############################

# UnitGFX-based triggers
artifact_use_african_unit_visuals_trigger = {
	exists = culture
	culture = { has_unit_gfx = sub_sahran_unit_gfx }
}

artifact_use_eastern_unit_visuals_trigger = {
	culture = { has_unit_gfx = eastern_unit_gfx }
}

artifact_use_indian_unit_visuals_trigger = {
	culture = { has_unit_gfx = indian_unit_gfx }
}

artifact_use_mena_unit_visuals_trigger = {
	culture = {
		OR = {
			has_unit_gfx = mena_unit_gfx
			has_unit_gfx = iberian_muslim_unit_gfx
		}
	}
}

artifact_use_northern_unit_visuals_trigger = {
	exists = culture
	culture = {
		OR = {
			has_unit_gfx = norse_unit_gfx
			has_unit_gfx = northern_unit_gfx
		}
	}
}

artifact_use_mongol_unit_visuals_trigger = {
	exists = culture
	culture = { has_unit_gfx = mongol_unit_gfx }
}

artifact_use_western_unit_visuals_trigger = {
	exists = culture
	culture = {
		OR = {
			has_unit_gfx = western_unit_gfx
			has_unit_gfx = eastern_unit_gfx
			has_unit_gfx = iberian_christian_unit_gfx
		}
	}
}

artifact_use_iberian_muslim_unit_visuals_trigger = {
	exists = culture
	culture = {	has_unit_gfx = iberian_muslim_unit_gfx }
}

artifact_use_iberian_christian_unit_visuals_trigger = {
	exists = culture
	culture = {	has_unit_gfx = iberian_christian_unit_gfx }
}

artifact_use_iranian_unit_visuals_trigger = {
	exists = culture
	culture = { has_unit_gfx = iranian_unit_gfx }
}

# BuildingGFX-based triggers
artifact_use_indian_building_visuals_trigger = {
	exists = culture
	culture = { has_building_gfx = indian_building_gfx }
}

artifact_use_mena_building_visuals_trigger = {
	exists = culture
	culture = { has_building_gfx = mena_building_gfx }
}

artifact_use_mediterranean_building_visuals_trigger = {
	exists = culture
	culture = { OR = {
		has_building_gfx = mediterranean_building_gfx
		has_building_gfx = byzantine_building_gfx }
	}
}

artifact_use_byzantine_building_visuals_trigger = {
	exists = culture
	culture = { has_building_gfx = byzantine_building_gfx }
}

artifact_use_iberian_building_visuals_trigger = {
	exists = culture
	culture = { has_building_gfx = iberian_building_gfx }
}

artifact_use_western_building_visuals_trigger = {
	exists = culture
	culture = { has_building_gfx = western_building_gfx }
}

artifact_use_norse_building_visuals_trigger = {
	exists = culture
	culture = { has_building_gfx = norse_building_gfx }
}

artifact_use_steppe_building_visuals_trigger = {
	exists = culture
	OR = {
		culture = { has_building_gfx = steppe_building_gfx }
		culture = { has_building_gfx = yamato_building_gfx }
	}
}

artifact_use_iranian_building_visuals_trigger = {
	exists = culture
	culture = { has_building_gfx = iranian_building_gfx }
}

artifact_use_berber_building_visuals_trigger = {
	exists = culture
	culture = { has_building_gfx = berber_group_building_gfx }
}

# GFX Trigger-picker

artifact_should_use_gfx_type_trigger = {
	trigger_if = {
		limit = { exists = scope:artifact.creator.culture }
		scope:artifact.creator = { artifact_use_$TYPE$_visuals_trigger = yes }
	}
	trigger_else_if = { #If the creator is not found we use the owner. Often this would be if the creator is a dummy, which has no culture
		limit = { exists = culture }
		artifact_use_$TYPE$_visuals_trigger = yes
	}
	trigger_else = {
		always = no #We should never get here as all created artifacts should have an owner.
	}
}

artifact_low_rarity_trigger = {
	scope:artifact ?= {
		OR = {
			rarity = masterwork
			rarity = common
		}
	}
}

artifact_medium_rarity_trigger = {
	scope:artifact ?= {
		OR = {
			rarity = masterwork
			rarity = famed
		}
	}
}

artifact_high_rarity_trigger = {
	scope:artifact ?= {
		OR = {
			rarity = famed
			rarity = illustrious
		}
	}
}

artifact_low_wealth_trigger = {
	OR = {	
		NOT = { exists = scope:wealth }
		trigger_if = {
			limit = { exists = scope:wealth }
			scope:wealth < low_high_wealth_cutoff
		}
	}	
}

artifact_high_wealth_trigger = {
	exists = scope:wealth
	scope:wealth >= low_high_wealth_cutoff
}

portrait_should_wield_axe_trigger = {
	trigger_if = {
		limit = {
			any_equipped_character_artifact = { artifact_slot_type = primary_armament }
			NOT = { has_variable = temporary_signature_weapon }
		}
		any_equipped_character_artifact = { artifact_type = axe }
	}
	trigger_else = {
		has_variable = signature_weapon
		var:signature_weapon = flag:axe
	}
}
portrait_should_wield_hammer_trigger = {
	trigger_if = {
		limit = {
			any_equipped_character_artifact = { artifact_slot_type = primary_armament }
			NOT = { has_variable = temporary_signature_weapon }
		}
		any_equipped_character_artifact = { artifact_type = hammer }
	}
	trigger_else = {
		has_variable = signature_weapon
		var:signature_weapon = flag:hammer
	}
}
portrait_should_wield_mace_trigger = {
	trigger_if = {
		limit = {
			any_equipped_character_artifact = { artifact_slot_type = primary_armament }
			NOT = { has_variable = temporary_signature_weapon }
		}
		any_equipped_character_artifact = { artifact_type = mace }
	}
	trigger_else = {
		has_variable = signature_weapon
		var:signature_weapon = flag:mace
	}
}
portrait_should_wield_spear_trigger = {
	trigger_if = {
		limit = {
			any_equipped_character_artifact = { artifact_slot_type = primary_armament }
			NOT = { has_variable = temporary_signature_weapon }
		}
		OR = {
			any_equipped_character_artifact = { artifact_type = spear }
			any_equipped_character_artifact = { artifact_type = japanese_spear }
		}
	}
	trigger_else = {
		has_variable = signature_weapon
		var:signature_weapon = flag:spear
	}
}
portrait_should_wield_dagger_trigger = {
	trigger_if = {
		limit = {
			any_equipped_character_artifact = { artifact_slot_type = primary_armament }
			NOT = { has_variable = temporary_signature_weapon }
		}
		OR = {
			any_equipped_character_artifact = { artifact_type = dagger }
			any_equipped_character_artifact = { artifact_type = japanese_dagger }
		}
	}
	trigger_else = {
		has_variable = signature_weapon
		var:signature_weapon = flag:dagger
	}
}
portrait_should_wield_sword_trigger = {
	trigger_if = {
		limit = {
			any_equipped_character_artifact = { artifact_slot_type = primary_armament }
			NOT = { has_variable = temporary_signature_weapon }
		}
		OR = {
			any_equipped_character_artifact = { artifact_type = sword }
			any_equipped_character_artifact = { artifact_type = japanese_sword }
		}
	}
	trigger_else = {
		has_variable = signature_weapon
		var:signature_weapon = flag:sword
	}
}
portrait_should_wield_wooden_sword_trigger = {
	has_variable = signature_weapon
	var:signature_weapon = flag:wooden_sword
}
#								 #
##################################
### Artifact Material Triggers ###
##################################
#								 #

##########################################
# Woods - Trees and Lumber
# Determines where various trees grow and, as a result, where products made from them is likely to be found
##########################################

# Found (Almost) Everywhere:
# ash
artifact_feature_wood_ash_trigger = {
	exists = scope:wealth
	scope:wealth < 50
	scope:wealth >= 0
	NOT = { artifact_region_trigger = { CHARACTER = scope:owner REGION = material_woods_subsaharan } }
}

# oak
artifact_feature_wood_oak_trigger = {
	always = yes #There must always be an available wood type
}


# Widespread Regional Woods - Europe/MENA:
# pine
artifact_feature_wood_pine_trigger = {
	trigger_if = { 
		limit = { exists = scope:wealth }
		artifact_value_trigger = { VALUE = scope:wealth MIN = 0 MAX = 50 }
	}
	trigger_else = {
		always = yes
	}
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_woods_pine_and_fir }
}

# fir
artifact_feature_wood_fir_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 10 MAX = 60 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_woods_pine_and_fir }
}

# elm
artifact_feature_wood_elm_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 10 MAX = 70 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_wood_elm }
}

# walnut
artifact_feature_wood_walnut_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 40 MAX = 999 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_wood_walnut }
}

# maple
artifact_feature_wood_maple_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 40 MAX = 999 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_wood_maple }
}


# Widespread Regional Woods - Subsaharan Africa
# fleroya
artifact_feature_wood_fleroya_trigger = {
	trigger_if = {
		limit = {
			exists = scope:wealth
		}
		artifact_value_trigger = { VALUE = scope:wealth MIN = 0 MAX = 50 }
	}
	trigger_else = {
		always = yes
	}
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_woods_subsaharan }
}

# sycomore
artifact_feature_wood_sycomore_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 30 MAX = 80 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_woods_subsaharan }
}

# padauk
artifact_feature_wood_padauk_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 60 MAX = 999 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_woods_padauk }
}


# Widespread Regional Woods - India
# sal
artifact_feature_wood_sal_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 20 MAX = 60 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_woods_india }
}

# rosewood
artifact_feature_wood_rosewood_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 50 MAX = 999 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_woods_india_burma }
}

# satinwood
artifact_feature_wood_satinwood_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 60 MAX = 999 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_woods_india_burma }
}

# teak
artifact_feature_wood_teak_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 70 MAX = 999 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_woods_india_burma }
}

# Local Regional Woods
# yew
artifact_feature_wood_yew_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 30 MAX = 70 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_woods_yew }
}

# olivewood
artifact_feature_wood_olivewood_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 45 MAX = 85 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_woods_mediterranean }
}

# coromandel
artifact_feature_wood_coromandel_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 70 MAX = 999 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_woods_sri_lanka }
}

# ebony
artifact_feature_wood_ebony_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 70 MAX = 999 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_woods_ebony }
}

# bamboo
artifact_feature_wood_bamboo_trigger = {
	artifact_value_trigger = { VALUE = scope:wealth MIN = 10 MAX = 90 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_woods_bamboo }
}

# cherry
artifact_feature_wood_cherry_trigger = {
	always = yes #There must always be an available wood type
}

# dogwood
artifact_feature_wood_dogwood_trigger = {
	artifact_value_trigger = { VALUE = scope:wealth MIN = 10 MAX = 90 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_woods_dogwood }
}

# hazel
artifact_feature_wood_hazel_trigger = {
	artifact_value_trigger = { VALUE = scope:wealth MIN = 10 MAX = 90 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_woods_hazel }
}

# hickory
artifact_feature_wood_hickory_trigger = {
	artifact_value_trigger = { VALUE = scope:wealth MIN = 10 MAX = 90 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_woods_hickory }
}

# mulberry
artifact_feature_wood_mulberry_trigger = {
	artifact_value_trigger = { VALUE = scope:wealth MIN = 10 MAX = 90 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_woods_mulberry }
}

# palm
artifact_feature_wood_palm_trigger = {
	artifact_value_trigger = { VALUE = scope:wealth MIN = 10 MAX = 90 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_woods_palm }
}

##########################################
# Cloths 
# Woven materials for clothing, tapestries, embroidery, ropes, etc.
##########################################

# Wool
# - Found literally everywhere
# wool
artifact_feature_cloth_wool_trigger = {
	trigger_if = {
		limit = { exists = scope:wealth }
		artifact_value_trigger = { VALUE = scope:wealth MIN = 0 MAX = 60 }
	}
	trigger_else = {
		always = yes
	}
}

# lambswool
artifact_feature_cloth_lambswool_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 60 MAX = 999 }
}


# Silk
#  - Found pretty much everywhere but subsaharan Africa.
# silk
artifact_feature_cloth_silk_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 40 MAX = 70 }
	NOT = { artifact_region_trigger = { CHARACTER = scope:owner REGION = material_cloth_no_silk } }
}	

# satin
artifact_feature_cloth_satin_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 50 MAX = 80 }
	NOT = { artifact_region_trigger = { CHARACTER = scope:owner REGION = material_cloth_no_silk } }
}	

# velvet
artifact_feature_cloth_velvet_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 60 MAX = 90 }
	NOT = { artifact_region_trigger = { CHARACTER = scope:owner REGION = material_cloth_no_silk } }
}		

# samite
artifact_feature_cloth_samite_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 70 MAX = 999 }
	NOT = { artifact_region_trigger = { CHARACTER = scope:owner REGION = material_cloth_no_silk } }
}	


# Linen
# - Modern Germany was a major producer of linen, which was exported throughout all of Europe (but not really beyond that)
# linen
artifact_feature_cloth_linen_trigger = {
	trigger_if = {
		limit = { exists = scope:wealth }
		artifact_value_trigger = { VALUE = scope:wealth MIN = 0 MAX = 60 }
	}
	trigger_else = {
		always = yes
	}
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_cloth_linen }
}

# fustian
artifact_feature_cloth_fustian_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 40 MAX = 70 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_cloth_linen }
	NOT = { scope:owner.religion = religion:judaism_religion }
}		


# Cotton
# - Cotton has been grown in Egypt since ancient times, spread to Etheopia early on and then in the late medieval period to Europe and India.
# cotton
artifact_feature_cloth_cotton_trigger = {
	trigger_if = {
		limit = { exists = scope:wealth }
		artifact_value_trigger = { VALUE = scope:wealth MIN = 10 MAX = 70 }
	}
	trigger_else = {
		always = yes
	}
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_cloth_cotton }
}


# British Isles
# worsted_wool
artifact_feature_cloth_worsted_wool_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 60 MAX = 999 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_cloth_cotton }
	current_date >= 1200.1.1
}	


##########################################
# HSB = Horn, Shell, Bone.
# Basically animal-based materials that have a wide array of applications — especially for carving, inlay, or other decorations.
##########################################

# Common. All regions should have access to at least one of these.
# hsb_camel_bone
artifact_feature_hsb_camel_bone_trigger = {
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_hsb_camel_bone }
}	

# hsb_deer_antler
artifact_feature_hsb_deer_antler_trigger = {
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_hsb_deer_antler }
}	

# hsb_boar_tusk
artifact_feature_hsb_boar_tusk_trigger = {
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_hsb_boar_tusk }
}	

# hsb_seashell
artifact_feature_hsb_seashell_trigger = {
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_hsb_seashell }
}	


# Rare, Expensive, or Region-Specifc. Not all regions will have access to these.
# hsb_tortoiseshell
artifact_feature_hsb_tortoiseshell_trigger = {
	AND = { 
		exists = scope:wealth
		artifact_value_trigger = { VALUE = scope:wealth MIN = 50 MAX = 999 }
		artifact_region_trigger = { CHARACTER = scope:owner REGION = material_hsb_tortoiseshell }
	}
}

# hsb_mother_of_pearl
artifact_feature_hsb_mother_of_pearl_trigger = {
	AND = { 
		exists = scope:wealth
		artifact_value_trigger = { VALUE = scope:wealth MIN = 50 MAX = 999 }
		artifact_region_trigger = { CHARACTER = scope:owner REGION = material_hsb_mother_of_pearl }
	}
}

# hsb_ivory
artifact_feature_hsb_ivory_native_trigger = {
	AND = { 
		exists = scope:wealth
		artifact_value_trigger = { VALUE = scope:wealth MIN = 50 MAX = 999 }
		artifact_region_trigger = { CHARACTER = scope:owner REGION = material_hsb_ivory_native }
	}
}

# hsb_ivory
artifact_feature_hsb_ivory_imported_trigger = {
	AND = { 
		exists = scope:wealth
		artifact_value_trigger = { VALUE = scope:wealth MIN = 80 MAX = 999 }
		artifact_region_trigger = { CHARACTER = scope:owner REGION = material_hsb_ivory_imported }
	}
}

# hsb_bison_horn
artifact_feature_hsb_bison_horn_trigger = {
	artifact_value_trigger = { VALUE = scope:wealth MIN = 10 MAX = 90 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = hunt_animal_bison_region }
}

# hsb_antelope_horn
artifact_feature_hsb_antelope_horn_trigger = {
	artifact_value_trigger = { VALUE = scope:wealth MIN = 10 MAX = 90 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = hunt_animal_antelope_region }
}

##########################################
# Animal type
# Basically an animal used in an artifact, for example as a wall ornament or hide
##########################################

# boar
artifact_feature_animal_boar_trigger = {
	trigger_if = {
		limit = { exists = scope:location }
		title_province = {
			NOT = {
				terrain = desert
				terrain = desert_mountains
			}
		}
	}
}

# lion
artifact_feature_animal_lion_trigger = {
	trigger_if = {
		limit = { exists = scope:location }
		scope:location = {
			OR = {
				terrain = forest
				terrain = jungle
				terrain = desert
				terrain = oasis
				terrain = desert_mountains
			}
			NOT = { geographical_region = world_europe }
		}
	}
}

# tiger
artifact_feature_animal_tiger_trigger = {
	trigger_if = {
		limit = { exists = scope:location }
		scope:location = {
			terrain = jungle
			geographical_region = world_india
		}
	}
}

# bear
artifact_feature_animal_bear_trigger = {
	trigger_if = {
		limit = { exists = scope:location }
		scope:location = { geographical_region = hunt_animal_bear_region }
	}
}

# aurochs
artifact_feature_animal_aurochs_trigger = {
	trigger_if = {
		limit = { exists = scope:location }
		scope:location = {
			NOR = {
				geographical_region = world_africa
				geographical_region = world_india
			}
		}
	}
}

#lynx
artifact_feature_animal_lynx_trigger = {
	trigger_if = {
		limit = { exists = scope:location }
		scope:location = {
			terrain = forest
			geographical_region = world_europe
		}
	}
}

# leopard
artifact_feature_animal_leopard_trigger = {
	trigger_if = {
		limit = { exists = scope:location }
		scope:location = { hunt_animal_leopard_trigger = yes }
	}
}

##########################################
# Patterns
# Any kind of decorative pattern which can be engraved/painted/drawn on something.
##########################################

# wolf
artifact_feature_pattern_wolf_trigger = {
	trigger_if = {
		limit = {
			exists = scope:newly_created_artifact
			scope:newly_created_artifact = { artifact_type = book }
		}
		scope:newly_created_artifact = {
			OR = {
				has_artifact_feature = book_subject_hunter
				has_artifact_feature = book_subject_cannibal
				has_artifact_feature = book_subject_mystical_animal
				has_artifact_feature = book_subject_animals
				has_artifact_feature = book_subject_martial
				has_artifact_feature = book_subject_intrigue
			}
		}
	}
	scope:owner = {
		faith = {
			NOR = {
				has_doctrine = tenet_aniconism
				religion = religion:islam_religion
			}
		}
	}
}	

# animals
artifact_feature_pattern_animals_trigger = {
	scope:owner = {
		faith = {
			NOR = {
				has_doctrine = tenet_aniconism
				religion = religion:islam_religion
			}
		}
	}
}	

# local_animal
artifact_feature_pattern_local_animal_trigger = {
	scope:owner = {
		faith = {
			NOR = {
				has_doctrine = tenet_aniconism
				religion = religion:islam_religion
			}
		}
	}
}	

# beasts
artifact_feature_pattern_beasts_trigger = {
	scope:owner = {
		faith = {
			NOR = {
				has_doctrine = tenet_aniconism
				religion = religion:islam_religion
			}
		}
	}
}	

# bird
artifact_feature_pattern_bird_trigger = {
	scope:owner = {
		faith = {
			NOR = {
				has_doctrine = tenet_aniconism
				religion = religion:islam_religion
			}
		}
	}
}	

# war_god
artifact_feature_pattern_war_god_trigger = {
	trigger_if = {
		limit = {
			exists = scope:newly_created_artifact
			scope:newly_created_artifact = { artifact_type = book }
		}
		scope:newly_created_artifact = {
			OR = {
				has_artifact_feature = book_subject_martial
				has_artifact_feature = book_subject_blademaster
				has_artifact_feature = book_subject_hunter
				has_artifact_feature = book_subject_mystical_animal
			}
		}
	}
	scope:owner = {
		faith = {
			NOR = {
				has_doctrine = tenet_aniconism
				has_doctrine = tenet_pacifism
			}
		}
	}
}

# religion
artifact_feature_pattern_religion_trigger = {
	trigger_if = {
		limit = {
			exists = scope:newly_created_artifact
			scope:newly_created_artifact = { artifact_type = book }
		}
		scope:newly_created_artifact = { has_artifact_feature = book_subject_learning }
	}
	scope:owner = {
		faith = {
			NOR = {
				has_doctrine = tenet_aniconism
				religion = religion:islam_religion
			}
		}
	}
}
# eschatology
artifact_feature_pattern_eschatology_trigger = {
	trigger_if = {
		limit = {
			exists = scope:newly_created_artifact
			scope:newly_created_artifact = { artifact_type = book }
		}
		scope:newly_created_artifact = {
			OR = {
				has_artifact_feature = book_subject_learning
				has_artifact_feature = book_subject_mystic
			}
		}
	}
	scope:owner = {
		faith = {
			NOR = {
				has_doctrine = tenet_aniconism
				religion = religion:islam_religion
			}
		}
	}
}
# pattern_religious_symbol
artifact_feature_pattern_religious_symbol_trigger = {
	trigger_if = {
		limit = {
			exists = scope:newly_created_artifact
			scope:newly_created_artifact = { artifact_type = book }
		}
		scope:newly_created_artifact = {
			OR = {
				has_artifact_feature = book_subject_learning
				has_artifact_feature = book_subject_mystic
			}
		}
	}
	scope:owner = {
		faith = {
			NOR = {
				has_doctrine = tenet_aniconism
				religion = religion:islam_religion
			}
		}
	}
}
# gibberish
artifact_feature_pattern_gibberish_trigger = {
	trigger_if = {
		limit = {
			exists = scope:newly_created_artifact
			scope:newly_created_artifact = { artifact_type = book }
		}
		scope:newly_created_artifact = {
			OR = {
				has_artifact_feature = book_subject_witch
				has_artifact_feature = book_subject_mystic
				has_artifact_feature = book_subject_lunatic
				has_artifact_feature = book_subject_childhood
			}
		}
	}
	scope:owner = {
		OR = {
			has_trait = lifestyle_mystic
			has_trait = paranoid
			has_trait = lunatic
			has_trait = witch
		}
	}
}
# pattern_culture_symbol
artifact_feature_pattern_culture_symbol_trigger = {
	trigger_if = {
		limit = {
			exists = scope:newly_created_artifact
			scope:newly_created_artifact = { artifact_type = book }
		}
		scope:newly_created_artifact = {
			OR = {
				has_artifact_feature = book_subject_empire
				has_artifact_feature = book_subject_kingdom
				has_artifact_feature = book_subject_dynasty
				has_artifact_feature = book_subject_stewardship
			}
		}
	}
	scope:owner = {
		has_royal_court = yes
		has_dlc_feature = royal_court
		court_grandeur_current_level > 1
	}
}

# pattern_culture_style
artifact_feature_pattern_culture_style_trigger = {
	trigger_if = {
		limit = {
			exists = scope:newly_created_artifact
			scope:newly_created_artifact = { artifact_type = book }
		}
		scope:newly_created_artifact = {
			OR = {
				has_artifact_feature = book_subject_empire
				has_artifact_feature = book_subject_kingdom
				has_artifact_feature = book_subject_dynasty
				has_artifact_feature = book_subject_stewardship
			}
		}
	}
	scope:owner = {
		has_royal_court = yes
		has_dlc_feature = royal_court
		court_grandeur_current_level > 1
	}
}

# pattern_dynasty_shield
artifact_feature_pattern_dynasty_shield_trigger = {
	trigger_if = {
		limit = {
			exists = scope:newly_created_artifact
			scope:newly_created_artifact = { artifact_type = book }
		}
		scope:newly_created_artifact = {
			OR = {
				has_artifact_feature = book_subject_empire
				has_artifact_feature = book_subject_kingdom
				has_artifact_feature = book_subject_dynasty
				has_artifact_feature = book_subject_stewardship
				has_artifact_feature = book_subject_diplomacy
			}
		}
	}
	exists = scope:owner.dynasty
	scope:owner.dynasty = { dynasty_prestige_level > medium_dynasty_prestige_level }
}

# pattern_dynasty_motifs
artifact_feature_pattern_dynasty_motifs_trigger = {
	trigger_if = {
		limit = {
			exists = scope:newly_created_artifact
			scope:newly_created_artifact = { artifact_type = book }
		}
		scope:newly_created_artifact = {
			OR = {
				has_artifact_feature = book_subject_empire
				has_artifact_feature = book_subject_kingdom
				has_artifact_feature = book_subject_dynasty
				has_artifact_feature = book_subject_stewardship
				has_artifact_feature = book_subject_diplomacy
			}
		}
	}
	exists = scope:owner.dynasty
	scope:owner.dynasty = { dynasty_prestige_level > medium_dynasty_prestige_level }
}

# roses
artifact_feature_pattern_roses_trigger = {
	always = yes
}

# floral
artifact_feature_pattern_floral_trigger = {
	always = yes
}

# geometric
artifact_feature_pattern_geometric_trigger = {
	always = yes
}

# quotes
artifact_feature_pattern_quotes_trigger = {
	trigger_if = {
		limit = { exists = scope:newly_created_artifact }
		NOT = { scope:newly_created_artifact = { artifact_type = book } }
	}
	always = yes
}

# knots
artifact_feature_pattern_knots_trigger = {
	always = yes
}

# bodies
artifact_feature_pattern_bodies_trigger = {
	trigger_if = {
		limit = { exists = scope:newly_created_artifact }
		scope:newly_created_artifact = {
			artifact_type = book
			OR = {
				has_artifact_feature = book_subject_cannibal
				has_artifact_feature = book_subject_deviant
				has_artifact_feature = book_subject_intrigue
			}
		}
	}
}

##########################################
# Metals
# Any mettalic resources used for either functional or decorative purposes.
##########################################

# Weapon Materials
# wrought_iron
artifact_feature_metal_wrought_iron_trigger = {
	always = yes
}

# folded_iron
artifact_feature_metal_folded_iron_trigger = {
	exists = scope:quality
	artifact_value_trigger = { VALUE = scope:quality MIN = 50 MAX = 999 }
}


# wootz_steel
artifact_feature_metal_wootz_steel_trigger = {
	exists = scope:wealth
	exists = scope:owner
	artifact_value_trigger = { VALUE = scope:wealth MIN = 80 MAX = 999 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_metal_wootz }	
}

# damascus_steel
artifact_feature_metal_damascus_steel_trigger = {
	exists = scope:wealth
	exists = scope:owner
	artifact_value_trigger = { VALUE = scope:wealth MIN = 80 MAX = 999 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_metal_damascus }
}

# bulat_steel
artifact_feature_metal_bulat_steel_trigger = {
	exists = scope:wealth
	exists = scope:owner
	artifact_value_trigger = { VALUE = scope:wealth MIN = 80 MAX = 999 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = material_metal_bulat }
}

# Decorative Materials
# gold
artifact_feature_metal_gold_trigger = {
	exists = scope:wealth
	scope:wealth >= 60
}	

# electrum
artifact_feature_metal_electrum_trigger = {
	exists = scope:wealth
	scope:wealth < 80
	scope:wealth >= 40
}

# silver
artifact_feature_metal_silver_trigger = {
	exists = scope:wealth
	scope:wealth < 60
	scope:wealth >= 20
}

# niello
artifact_feature_metal_niello_trigger = {
	exists = scope:wealth
	scope:wealth < 70
	scope:wealth >= 30
}

# brass
artifact_feature_metal_brass_trigger = {
	trigger_if = {
		limit = { exists = scope:wealth }
		scope:wealth < 40
	}
	trigger_else = {
		always = yes
	}
}

# pewter
artifact_feature_metal_pewter_trigger = {
	trigger_if = {
		limit = { exists = scope:wealth }
		scope:wealth < 30
	}
	trigger_else = {
		always = yes
	}
}

# bronze
artifact_feature_metal_bronze_trigger = {
	trigger_if = {
		limit = { exists = scope:wealth }
		scope:wealth < 40
	}
	trigger_else = {
		always = yes
	}
}

# copper
artifact_feature_metal_copper_trigger = {
	trigger_if = {
		limit = { exists = scope:wealth }
		scope:wealth < 40
	}
	trigger_else = {
		always = yes
	}
}

# clay
artifact_feature_earthware_clay_trigger = {
	always = yes
}

# terracotta
artifact_feature_earthware_terracotta_trigger = {
	always = yes
}

# stone
artifact_feature_earthware_stone_trigger = {
	trigger_if = {
		limit = { exists = scope:potter }
		scope:potter.culture = { has_cultural_pillar = heritage_chinese }
	}
	trigger_else = {
		always = no
	}
	trigger_if = {
		limit = { exists = scope:wealth }
		scope:wealth < 80
	}
	trigger_else = {
		always = yes
	}
}

# porcelain
artifact_feature_earthware_porcelain_trigger = {
	trigger_if = {
		limit = { exists = scope:potter }
		scope:potter.culture = { has_cultural_pillar = heritage_chinese }
	}
	trigger_else = {
		always = no
	}
	trigger_if = {
		limit = { exists = scope:wealth }
		scope:wealth >= 60
	}
	trigger_else = {
		always = no
	}
}




##########################################
# Gemstones
# Natural minerals or organic gemstones (such as amber) used to decorate ob
##########################################

# Cheap/Common Gems, Everywhere
# rock_crystal
artifact_feature_gem_rock_crystal_trigger = {
	trigger_if = {
		limit = {
			exists = scope:wealth
		}
		artifact_value_trigger = { VALUE = scope:wealth MIN = 0 MAX = 20 }
	}
	trigger_else = {
		always = yes
	}
}

# jet
artifact_feature_gem_jet_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 10 MAX = 30 }
}	

# agate
artifact_feature_gem_agate_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 20 MAX = 40 }
}	

# onyx
artifact_feature_gem_onyx_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 20 MAX = 40 }
}	


# Semi-Precious Gems, Everywhere
# jasper
artifact_feature_gem_jasper_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 30 MAX = 50 }
}	

# zircon
artifact_feature_gem_zircon_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 35 MAX = 60 }
}	

# garnet
artifact_feature_gem_garnet_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 40 MAX = 70 }
}	


# Rare/Precious Gems, Everywhere
# sapphire
artifact_feature_gem_sapphire_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 50 MAX = 999 }
} 

# emerald
artifact_feature_gem_emerald_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 60 MAX = 999 }
} 

# ruby
artifact_feature_gem_ruby_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 70 MAX = 999 }
} 

# Semi-Precious Gems, Regional
# flourite
artifact_feature_gem_flourite_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 20 MAX = 60 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = world_europe_west_britannia }	
}		

# adventurine
artifact_feature_gem_adventurine_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 20 MAX = 60 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = world_europe_west_iberia }	
}		

# amethyst
artifact_feature_gem_amethyst_trigger = {
	artifact_value_trigger = { VALUE = scope:wealth MIN = 20 MAX = 60 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = world_europe_west_francia }
}	

# amber
artifact_feature_gem_amber_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 20 MAX = 70 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = custom_eastern_baltic}
}	

# moonstone
artifact_feature_gem_moonstone_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 20 MAX = 70 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = world_india }
}

# turquoise
artifact_feature_gem_turquoise_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 20 MAX = 70 }
	OR = {
		artifact_region_trigger = { CHARACTER = scope:owner REGION = world_asia_minor }
		artifact_region_trigger = { CHARACTER = scope:owner REGION = world_middle_east_persia }
	}
}

# carnelian
artifact_feature_gem_carnelian_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 20 MAX = 70 }
	OR = {
		artifact_region_trigger = { CHARACTER = scope:owner REGION = world_europe_west_germania }
		artifact_region_trigger = { CHARACTER = scope:owner REGION = world_europe_north }
	}
}	


# Rare/Precious Gems, Regional
# peridot
artifact_feature_gem_peridot_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 40 MAX = 80 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = world_india_deccan }
}	

# lapis_lazuli
artifact_feature_gem_lapis_lazuli_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 40 MAX = 90 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = world_middle_east_persia }
}

# opal
artifact_feature_gem_opal_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 40 MAX = 90 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = world_africa_east }
}		

# spinel
artifact_feature_gem_spinel_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 40 MAX = 90 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = world_india_deccan }
}

# jade
artifact_feature_gem_jade_trigger = {
	exists = scope:wealth
	artifact_value_trigger = { VALUE = scope:wealth MIN = 40 MAX = 90 }
	artifact_region_trigger = { CHARACTER = scope:owner REGION = world_india_bengal }
}

##########################################
# Books
# 
##########################################

artifact_book_topic_preface_trigger = {
	OR = {
		has_artifact_feature = book_topic_unification
		has_artifact_feature = book_topic_creation
		has_artifact_feature = book_topic_restoration
		has_artifact_feature = book_topic_martial_troop_compositions
		has_artifact_feature = book_topic_martial_military_strategies
		has_artifact_feature = book_topic_martial_ancient_military_campaigns
		has_artifact_feature = book_topic_diplomacy_court_politics
		has_artifact_feature = book_topic_diplomacy_court_alliances
		has_artifact_feature = book_topic_diplomacy_art_of_feasting
		has_artifact_feature = book_topic_learning_theological_treaties
		has_artifact_feature = book_topic_learning_metaphysical_conundrums
		has_artifact_feature = book_topic_learning_tome_collections
		has_artifact_feature = book_topic_stewardship_trade_routes
		has_artifact_feature = book_topic_stewardship_lawmaking
		has_artifact_feature = book_topic_stewardship_best_practices_tax_collectors
		has_artifact_feature = book_topic_intrigue_poisons
		has_artifact_feature = book_topic_intrigue_the_art_of_love
		has_artifact_feature = book_topic_medicine_medicine
		has_artifact_feature = book_topic_medicine_herbs
		has_artifact_feature = book_topic_medicine_witch
		has_artifact_feature = book_topic_artifact_book_topic_cannibal
		has_artifact_feature = book_topic_lunatic_lunatic
		has_artifact_feature = book_topic_mystic_mystic
		has_artifact_feature = book_topic_hunter_hunter
		has_artifact_feature = book_topic_witch_worship_horned_god
	}
}


book_subject_martial_trigger = {
	OR = {
		prowess >= high_skill_rating
		has_trait = faith_warrior
		has_trait = crusader_king
		has_trait = viking
		number_of_commander_traits >= 1
	}
}

book_subject_medicine_trigger = {
	OR = {
		has_trait = lifestyle_physician
		has_trait = lifestyle_herbalist
		has_focus = learning_medicine_focus
	}
}

book_subject_medicine_witch_trigger = {
	OR = {
		has_trait = lifestyle_physician
		has_trait = lifestyle_mystic
		has_trait = lifestyle_herbalist
		has_focus = learning_medicine_focus
		is_witch_trigger = yes
	}
}

book_subject_witch_trigger = {
	OR = {
		has_trait = arrogant
		has_trait = witch
	}
}

book_subject_cannibal_trigger = {
	OR = {
		has_trait = arrogant
		has_trait = cannibal
	}
}

book_subject_deviant_trigger = {
	OR = {
		has_trait = arrogant
		has_trait = deviant
	}
}

book_subject_torturer_trigger = {
	OR = {
		has_trait = torturer
		has_trait = sadistic
	}
}

book_subject_animals_trigger = {
	OR = {
		has_trait = lifestyle_hunter
		AND = {
			any_owned_story = { story_type = story_cycle_pet_cat }
			exists = var:story_cycle_cat_name
		}
		AND = {
			any_owned_story = { story_type = story_cycle_pet_dog }
			exists = var:story_cycle_dog_name
		}
	}
}

book_topic_martial_military_strategies_trigger = {
	OR = {
		has_focus_or_focus_trait_trigger = { FOCUS = martial_strategy_focus }
		has_trait_rank = {
			trait = education_martial
			rank >= 2
		}
	}
}

book_topic_martial_ancient_military_campaigns_trigger = {
	OR = {
		has_focus_or_focus_trait_trigger = { FOCUS = martial_strategy_focus }
		has_trait_rank = {
			trait = education_martial
			rank >= 2
		}
	}
}

book_topic_martial_military_trigger = {
	OR = {
		has_focus_or_focus_trait_trigger = { FOCUS = martial_strategy_focus }
		has_trait_rank = {
			trait = education_martial
			rank >= 2
		}
	}
}

book_topic_martial_duels_trigger = {
	OR = {
		has_focus_or_focus_trait_trigger = { FOCUS = martial_chivalry_focus }
		has_trait_rank = {
			trait = education_martial
			rank >= 2
		}
	}
}

book_topic_martial_chivalry_trigger = {
	OR = {
		has_martial_lifestyle_trait_trigger = yes
		has_focus_or_focus_trait_trigger = { FOCUS = martial_chivalry_focus }
		has_trait_rank = {
			trait = education_martial
			rank >= 2
		}
	}
}

book_topic_diplomacy_court_politics_trigger = {
	OR = {
		has_focus_or_focus_trait_trigger = { FOCUS = diplomacy_majesty_focus }
		has_trait_rank = {
			trait = education_diplomacy
			rank >= 2
		}
	}
}

book_topic_diplomacy_court_alliances_trigger = {
	OR = {
		has_focus_or_focus_trait_trigger = { FOCUS = diplomacy_majesty_focus }
		has_trait_rank = {
			trait = education_diplomacy
			rank >= 2
		}
	}
}

book_topic_diplomacy_jokes_trigger = {
	OR = { #the jokes we tell to hide the pain...!
		has_trait = depressed
		has_trait = lunatic
		has_trait = possessed
	}
}

book_topic_learning_theological_treaties = {
	OR = {
		has_focus_or_focus_trait_trigger = { FOCUS = learning_theology_focus }
		has_trait_rank = {
			trait = education_learning
			rank >= 2
		}
	}
}

book_topic_learning_tome_collections_trigger = {
	OR = {
		has_focus_or_focus_trait_trigger = { FOCUS = learning_scholarship_focus }
		has_trait_rank = {
			trait = education_learning
			rank >= 2
		}
	}
}

book_topic_stewardship_lawmaking_trigger = {
	OR = {
		has_focus_or_focus_trait_trigger = { FOCUS = stewardship_duty_focus }
		has_trait_rank = {
			trait = education_stewardship
			rank >= 2
		}
	}
}

book_topic_stewardship_best_practices_tax_collectors_trigger = {
	OR = {
		has_focus_or_focus_trait_trigger = { FOCUS = stewardship_wealth_focus }
		has_trait_rank = {
			trait = education_stewardship
			rank >= 2
		}
	}
}

book_topic_intrigue_poisons_trigger = {
	OR = {
		has_focus_or_focus_trait_trigger = { FOCUS = intrigue_skulduggery_focus }
		has_trait_rank = {
			trait = education_intrigue
			rank >= 2
		}
	}
}

book_topic_intrigue_punishment_trigger = {
	OR = {
		has_focus_or_focus_trait_trigger = { FOCUS = intrigue_intimidation_focus }
		has_trait_rank = {
			trait = education_intrigue
			rank >= 2
		}
		has_trait = torturer
	}
}

book_topic_intrigue_seduction_trigger = {
	OR = {
		has_trait = lustful
		has_trait = seducer
		has_focus = intrigue_temptation_focus
		has_trait = deviant
		has_trait = rakish
	}
}

book_topic_medicine_herbs_trigger = {
	OR = {
		has_trait = lifestyle_herbalist
		is_witch_trigger = yes
	}
}

book_topic_witch_love_sorcery_trigger = {
	OR = {
		has_trait = seducer
		has_focus = intrigue_temptation_focus
	}
}

book_topic_witch_curse_sorcery_trigger = {
	OR = {
		dread >= medium_dread
		has_trait = sadistic
		has_trait = vengeful
		has_trait = torturer
		has_trait = paranoid
	}
}

# Saintly Bones
saintly_bones_faith_trigger = { # christianity is of the right kind
	trigger_if = {
		limit = {
			OR = {
				scope:artifact.var:saint_bone_faith = faith:catholic
				scope:artifact.var:saint_bone_faith = faith:orthodox
			}
		}
		OR = {
			faith = faith:catholic
			faith = faith:orthodox
			faith = { has_doctrine = tenet_christian_syncretism }
		}
	}
	trigger_else_if = {
		limit = {
			OR = {
				scope:artifact.var:saint_bone_faith = faith:nestorian
				scope:artifact.var:saint_bone_faith = faith:coptic
				scope:artifact.var:saint_bone_faith = faith:armenian_apostolic
			}
		}
		OR = {
			faith = faith:nestorian
			faith = faith:coptic
			faith = faith:armenian_apostolic
		}
	}
	trigger_else_if = {
		limit = { scope:artifact.var:saint_bone_faith = faith:insular_celtic }
		faith = faith:insular_celtic
	}
	trigger_else = {
		OR = {
			faith = faith:catholic
			faith = faith:orthodox
			faith = faith:nestorian
			faith = faith:coptic
			faith = faith:armenian_apostolic
			faith = faith:insular_celtic
			faith = { has_doctrine = tenet_christian_syncretism }
		}
	}
}

#Used after setting local animal to determine if a skull artifact/trophy can be made from that animal.
can_animal_produce_skull_trigger = {
	exists = $VARIABLE$
	NOR = {
		$VARIABLE$ = flag:dragon
		$VARIABLE$ = flag:hart
		$VARIABLE$ = flag:fox
		$VARIABLE$ = flag:hare
		$VARIABLE$ = flag:lynx
	}
}

# Duel cultures
axe_unique_gfx_trigger = {
	culture = {
		OR = {
			has_clothing_gfx = northern_clothing_gfx
			has_clothing_gfx = mongol_clothing_gfx
			has_clothing_gfx = byzantine_clothing_gfx
			has_clothing_gfx = indian_clothing_gfx
			has_clothing_gfx = african_clothing_gfx
			has_clothing_gfx = mena_clothing_gfx
			has_clothing_gfx = iranian_clothing_gfx
			has_clothing_gfx = iberian_christian_clothing_gfx
			has_clothing_gfx = iberian_muslim_clothing_gfx
		}
	}
}

sword_unique_gfx_trigger = {
	culture = {
		OR = {
			has_clothing_gfx = northern_clothing_gfx
			has_clothing_gfx = mongol_clothing_gfx
			has_clothing_gfx = byzantine_clothing_gfx
			has_clothing_gfx = indian_clothing_gfx
			has_clothing_gfx = african_clothing_gfx
			has_clothing_gfx = mena_clothing_gfx
			has_clothing_gfx = iberian_christian_clothing_gfx
			has_clothing_gfx = iberian_muslim_clothing_gfx
			has_clothing_gfx = iranian_clothing_gfx
		}
	}
}

hammer_unique_gfx_trigger = {
	culture = {
		OR = {
			has_clothing_gfx = african_clothing_gfx
			has_clothing_gfx = mongol_clothing_gfx
			has_clothing_gfx = indian_clothing_gfx
			has_clothing_gfx = mena_clothing_gfx
			has_clothing_gfx = iberian_christian_clothing_gfx
			has_clothing_gfx = iberian_muslim_clothing_gfx
		}
	}
}

dagger_unique_gfx_trigger = {
	culture = {
		OR = {
			has_clothing_gfx = iberian_christian_clothing_gfx
			has_clothing_gfx = iberian_muslim_clothing_gfx
			has_clothing_gfx = indian_clothing_gfx
		}
	}
}

mace_unique_gfx_trigger = {
	culture = {
		OR = {
			has_clothing_gfx = mongol_clothing_gfx
			has_clothing_gfx = byzantine_clothing_gfx
			has_clothing_gfx = indian_clothing_gfx
			has_clothing_gfx = african_clothing_gfx
			has_clothing_gfx = mena_clothing_gfx
			has_clothing_gfx = iberian_christian_clothing_gfx
			has_clothing_gfx = iberian_muslim_clothing_gfx
		}
	}
}

spear_unique_gfx_trigger = {
	culture = {
		OR = {
			has_clothing_gfx = indian_clothing_gfx
			has_clothing_gfx = mongol_clothing_gfx
			has_clothing_gfx = african_clothing_gfx
			has_clothing_gfx = mena_clothing_gfx
			has_clothing_gfx = iberian_christian_clothing_gfx
			has_clothing_gfx = iberian_muslim_clothing_gfx
			has_clothing_gfx = iranian_clothing_gfx
		}
	}
}

# Scientific Apparatus Availability

eligible_for_scientific_apparatus_armillary_sphere_trigger = {
	has_fp2_dlc_trigger = yes
	$CHARACTER$ = {
		culture = { has_innovation = innovation_armilary_sphere }
		OR = {
			# Wide spread in the Arabic world fairly early.

			has_court_language = language_arabic
			has_court_language = language_iranian #FP3 addition 


			knows_language = language_arabic
			# Becomes commonplace towards the end of the period.
			culture = { has_cultural_era_or_later = culture_era_late_medieval }
			trigger_if = {
				limit = { has_royal_court = yes }
				OR = {
					has_court_language = language_arabic
					# Nerds can import the knowledge.
					has_court_type = court_scholarly
				}
			}
		}
	}
}

# Relic War Validity

relic_war_valid_religious_artefact_trigger = {
	exists = var:relic
	scope:attacker = {
		can_benefit_from_artifact = prev
	}
	NOT = {
		scope:defender = {
			can_benefit_from_artifact = prev
		}
	}
}

relic_war_valid_struggle_artefact_trigger = {
	exists = var:relic
	var:relic = flag:iberian_struggle
	scope:attacker = {
		any_character_struggle = { is_struggle_type = iberian_struggle }
		# Plus one of the valid using faiths.
		OR = {
			islam_or_syncretic_with_islam_trigger = { CHARACTER = scope:attacker }
			christianity_or_syncretic_with_christianity_trigger = { CHARACTER = scope:attacker }
		}
	}
	NOT = { scope:attacker.faith = scope:defender.faith }

}

relic_war_valid_against_defender_trigger = {
	any_character_artifact = {
		exists = var:relic
		OR = {
			# Standard relics.
			AND = {
				scope:attacker = {
					can_benefit_from_artifact = prev
				}
				NOT = {
					scope:defender = {
						can_benefit_from_artifact = prev
					}
				}
			}
			# Struggle relics.
			## The Bells of Santiago de Compostela.
			AND = {
				var:relic = flag:iberian_struggle
				scope:attacker = {
					any_character_struggle = { is_struggle_type = iberian_struggle }
					# Plus one of the valid using faiths.
					OR = {
						islam_or_syncretic_with_islam_trigger = { CHARACTER = scope:attacker }
						christianity_or_syncretic_with_christianity_trigger = { CHARACTER = scope:attacker }
					}
				}
				NOT = { scope:attacker.faith = scope:defender.faith }
			}
		}
	}
}

relic_war_valid_against_defender_vassal_trigger = {
	any_vassal_or_below = {
		NOT = {
			faith = scope:attacker.faith
		}
		any_character_artifact = {
			exists = var:relic
			OR = {
				# Standard relics.
				AND = {
					scope:attacker = {
						can_benefit_from_artifact = prev
					}
					NOT = {
						scope:defender = {
							can_benefit_from_artifact = prev
						}
					}
				}
				# Struggle relics.
				## The Bells of Santiago de Compostela.
				AND = {
					var:relic = flag:iberian_struggle
					scope:attacker = {
						any_character_struggle = { is_struggle_type = iberian_struggle }
						# Plus one of the valid using faiths.
						OR = {
							islam_or_syncretic_with_islam_trigger = { CHARACTER = scope:attacker }
							christianity_or_syncretic_with_christianity_trigger = { CHARACTER = scope:attacker }
						}
					}
					NOT = { scope:attacker.faith = scope:defender.faith }
				}
			}
		}
	}
}

portrait_should_wield_longbow_trigger = {
	trigger_if = {
		limit = {
			any_equipped_character_artifact = {
				OR = {
					artifact_type = longbow
					artifact_type = bow
				}
			}
		}
		OR = {
			any_equipped_character_artifact = { artifact_type = longbow }
			any_equipped_character_artifact = {
				artifact_type = bow
				creator ?= { artifact_use_indian_unit_visuals_trigger = yes }
			}
		}
	}
	trigger_else = {
		culture = {
			OR = {
				has_cultural_tradition = tradition_longbow_competitions
				has_clothing_gfx = indian_clothing_gfx
			}
		}
	}
}

portrait_should_wield_crossbow_trigger = {
	any_equipped_character_artifact = { artifact_type = crossbow }
}

artifact_war_claimable_artifact_trigger = {
	artifact_owner = {
		is_ruler = yes
		target_is_same_character_or_above = scope:defender
	}
	trigger_if ={
		limit = {
			scope:attacker = { is_ai = yes }
		}
		NOT = { has_variable = cursed_artifact }
		artifact_rarity >= 4 #More than masterwork
		save_temporary_scope_as = artifact_temp
		scope:attacker = { can_benefit_from_artifact = scope:artifact_temp } 
	}
}

sword_could_be_longsword_trigger = {
	trigger_if = {
		limit = { exists = scope:artifact.creator.culture }
		scope:artifact.creator.culture = {
			has_unit_gfx = western_unit_gfx
			has_cultural_era_or_later = culture_era_late_medieval
		}
	}
	trigger_else_if = { #If the creator is not found we use the owner. Often this would be if the creator is a dummy, which has no culture
		limit = { exists = culture }
		culture = {
			has_unit_gfx = western_unit_gfx
			has_cultural_era_or_later = culture_era_late_medieval
		}
	}
	trigger_else = {
		always = no #We should never get here as all created artifacts should have an owner.
	}
}

any_recent_previous_owner = {
	OR = {
		previous_owner = $OWNER$
		previous_owner_level_2 = $OWNER$
		previous_owner_level_3 = $OWNER$
	}
}
